package com.hailiao.beidou.message.ui.page.chat.view

import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.hailiao.beidou.message.R
import com.hailiao.beidou.message.data.db.constant.SendStatus
import com.hailiao.beidou.message.ui.view.RotatingImage

/**
 * 消息状态图标
 * @Author d10ng
 * @Date 2023/11/22 15:17
 */
@Composable
fun MessageStatusIcon(
    modifier: Modifier = Modifier,
    status: SendStatus
) {
    val icon = remember(status) {
        when(status) {
            SendStatus.SUCCESS -> R.drawable.message_status_success
            SendStatus.FAILED -> R.drawable.message_status_fail
            else -> R.drawable.message_status_sending
        }
    }
    val rotating = remember(status) {
        status == SendStatus.SENDING
    }
    RotatingImage(
        modifier = modifier.size(20.dp),
        painter = painterResource(id = icon),
        rotating = rotating
    )
}